Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(azkv): handle whitespace in Azure Key Vault URLs #1652

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

sEpt0r
Copy link
Contributor

@sEpt0r sEpt0r commented Oct 19, 2024

Problem:

The Azure Key Vault key parser would fail when URLs contained leading or trailing whitespace, which commonly occurs when using YAML Block Scalar syntax.

creation_rules:
  - azure_keyvault: >-
      https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90,
      https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e

This resulted in the error:

could not parse " https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e" into a valid Azure Key Vault MasterKey

Fix:

  • Added strings.TrimSpace() to clean the URL before parsing in NewMasterKeyFromURL()
  • Added test case to verify handling of URLs with leading/trailing spaces

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Sorry for missing it on Saturday, I only noticed it now that you created the issue.

### Problem:

The Azure Key Vault key parser would fail when URLs contained leading or trailing whitespace, which commonly occurs when using YAML Block Scalar syntax.

```yaml
creation_rules:
  - azure_keyvault: >-
      https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90,
      https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e
```

This resulted in the error:

```bash
"could not parse " https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e" into a valid Azure Key Vault MasterKey"
```

### Fix:

- Added `strings.TrimSpace()` to clean the URL before parsing in `NewMasterKeyFromURL()`
- Added test case to verify handling of URLs with leading/trailing spaces

Signed-off-by: Vasily Marnopolsky <[email protected]>
@felixfontein felixfontein merged commit e0c970a into getsops:main Oct 22, 2024
15 checks passed
@felixfontein
Copy link
Contributor

@sEpt0r thanks for your contribution!

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Dec 5, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [getsops/sops](https://github.com/getsops/sops) | patch | `v3.9.1` -> `v3.9.2` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>getsops/sops (getsops/sops)</summary>

### [`v3.9.2`](https://github.com/getsops/sops/releases/tag/v3.9.2)

[Compare Source](getsops/sops@v3.9.1...v3.9.2)

#### Installation

To install `sops`, download one of the pre-built binaries provided for your platform from the artifacts attached to this release.

For instance, if you are using Linux on an AMD64 architecture:

```shell

### Download the binary
curl -LO https://github.com/getsops/sops/releases/download/v3.9.2/sops-v3.9.2.linux.amd64

### Move the binary in to your PATH
mv sops-v3.9.2.linux.amd64 /usr/local/bin/sops

### Make the binary executable
chmod +x /usr/local/bin/sops
```

##### Verify checksums file signature

The checksums file provided within the artifacts attached to this release is signed using [Cosign](https://docs.sigstore.dev/cosign/overview/) with GitHub OIDC. To validate the signature of this file, run the following commands:

```shell

### Download the checksums file, certificate and signature
curl -LO https://github.com/getsops/sops/releases/download/v3.9.2/sops-v3.9.2.checksums.txt
curl -LO https://github.com/getsops/sops/releases/download/v3.9.2/sops-v3.9.2.checksums.pem
curl -LO https://github.com/getsops/sops/releases/download/v3.9.2/sops-v3.9.2.checksums.sig

### Verify the checksums file
cosign verify-blob sops-v3.9.2.checksums.txt \
  --certificate sops-v3.9.2.checksums.pem \
  --signature sops-v3.9.2.checksums.sig \
  --certificate-identity-regexp=https://github.com/getsops \
  --certificate-oidc-issuer=https://token.actions.githubusercontent.com
```

##### Verify binary integrity

To verify the integrity of the downloaded binary, you can utilize the checksums file after having validated its signature:

```shell

### Verify the binary using the checksums file
sha256sum -c sops-v3.9.2.checksums.txt --ignore-missing
```

##### Verify artifact provenance

The [SLSA provenance](https://slsa.dev/provenance/v0.2) of the binaries, packages, and SBOMs can be found within the artifacts associated with this release. It is presented through an [in-toto](https://in-toto.io/) link metadata file named `sops-v3.9.2.intoto.jsonl`. To verify the provenance of an artifact, you can utilize the [`slsa-verifier`](https://github.com/slsa-framework/slsa-verifier#artifacts) tool:

```shell

### Download the metadata file
curl -LO  https://github.com/getsops/sops/releases/download/v3.9.2/sops-v3.9.2.intoto.jsonl

### Verify the provenance of the artifact
slsa-verifier verify-artifact <artifact> \
  --provenance-path sops-v3.9.2.intoto.jsonl \
  --source-uri github.com/getsops/sops \
  --source-tag v3.9.2
```

#### Container Images

The `sops` binaries are also available as container images, based on Debian (slim) and Alpine Linux. The Debian-based container images include any dependencies which may be required to make use of certain key services, such as GnuPG, AWS KMS, Azure Key Vault, and Google Cloud KMS. The Alpine-based container images are smaller in size, but do not include these dependencies.

These container images are available for the following architectures: `linux/amd64` and `linux/arm64`.

##### GitHub Container Registry

-   `ghcr.io/getsops/sops:v3.9.2`
-   `ghcr.io/getsops/sops:v3.9.2-alpine`

##### Quay.io

-   `quay.io/getsops/sops:v3.9.2`
-   `quay.io/getsops/sops:v3.9.2-alpine`

##### Verify container image signature

The container images are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/) with GitHub OIDC. To validate the signature of an image, run the following command:

```shell
cosign verify ghcr.io/getsops/sops:v3.9.2 \
  --certificate-identity-regexp=https://github.com/getsops \
  --certificate-oidc-issuer=https://token.actions.githubusercontent.com \
  -o text
```

##### Verify container image provenance

The container images include [SLSA provenance](https://slsa.dev/provenance/v0.2) attestations. For more information around the verification of this, please refer to the [`slsa-verifier` documentation](https://github.com/slsa-framework/slsa-verifier#containers).

#### Software Bill of Materials

The Software Bill of Materials (SBOM) for each binary is accessible within the artifacts enclosed with this release. It is presented as an [SPDX](https://spdx.dev/) JSON file, formatted as `<binary>.spdx.sbom.json`.

#### What's Changed

-   build(deps): Bump the go group with 11 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1645
-   build(deps): Bump the ci group with 4 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1644
-   build(deps): Bump the go group with 12 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1649
-   build(deps): Bump the ci group with 5 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1648
-   build(deps): Bump the go group with 6 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1653
-   build(deps): Bump the ci group with 2 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1654
-   build(deps): Bump serde_json from 1.0.128 to 1.0.132 in /functional-tests in the rust group by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1655
-   fix(azkv): handle whitespace in Azure Key Vault URLs by [@&#8203;sEpt0r](https://github.com/sEpt0r) in getsops/sops#1652
-   build(deps): Bump the go group with 7 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1662
-   build(deps): Bump the ci group with 5 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1664
-   build(deps): Bump the rust group in /functional-tests with 2 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1663
-   build(deps): Bump the ci group across 1 directory with 3 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1673
-   build(deps): Bump the rust group in /functional-tests with 2 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1670
-   build(deps): Bump github/codeql-action from 3.27.1 to 3.27.4 in the ci group by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1677
-   build(deps): Bump the rust group in /functional-tests with 3 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1676
-   build(deps): Bump the ci group with 2 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1685
-   build(deps): Bump the go group across 1 directory with 18 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1686
-   Correctly handle comments during JSON serialization by [@&#8203;felixfontein](https://github.com/felixfontein) in getsops/sops#1647
-   Update Rust dependencies by [@&#8203;felixfontein](https://github.com/felixfontein) in getsops/sops#1689
-   fix(config): remove unused variables and align error casing by [@&#8203;nicklasfrahm](https://github.com/nicklasfrahm) in getsops/sops#1687
-   keyservice: update protobuf to a recent release, and make go code generation reproducible by [@&#8203;felixfontein](https://github.com/felixfontein) in getsops/sops#1688
-   build(deps): Bump the go group with 8 updates by [@&#8203;dependabot](https://github.com/dependabot) in getsops/sops#1693
-   Release 3.9.2 by [@&#8203;felixfontein](https://github.com/felixfontein) in getsops/sops#1691

#### New Contributors

-   [@&#8203;sEpt0r](https://github.com/sEpt0r) made their first contribution in getsops/sops#1652
-   [@&#8203;nicklasfrahm](https://github.com/nicklasfrahm) made their first contribution in getsops/sops#1687

**Full Changelog**: getsops/sops@v3.9.1...v3.9.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Key Vault URL parsing error when using YAML '>-' block style
2 participants